package cn.jh.clearing.business;

import cn.jh.clearing.pojo.PaymentOrder;
import cn.jh.clearing.pojo.PaymentQueryCriteria;
import cn.jh.common.exception.ServiceException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface PaymentOrderBusiness {

	List<PaymentOrder> queryWaitClearingOrders();

	List<PaymentOrder> queryWeekBrandWithdrawRebate(Date startDate, Date endDate);
	
	List<PaymentOrder> queryWeekBrandWithdrawClearRebate(Date startDate, Date endDate);

	/**
	 * 查询指定订单信息(NEW)
	 *
	 * @param queryCriteria 查询条件封装
	 * @param pageable 分页查询参数
	 * @return 返回订单信息集合
	 */
	Page<PaymentOrder> findPaymentOrder(PaymentQueryCriteria queryCriteria, Pageable pageable);

	/**
	 * 查询指定订单信息(NEW)
	 *
	 * @param queryCriteria 查询条件封装
	 * @return 返回订单信息集合
	 */
	List<PaymentOrder> findPaymentOrder(PaymentQueryCriteria queryCriteria);
	
	PaymentOrder  mergePaymentOrder(PaymentOrder order);
	
	PaymentOrder  queryPaymentOderByOutOrdercode(String outordercode);
	
	PaymentOrder  queryPaymentOrderByThirdcode(String thirdcode);
	
	void updateThirdcodeByOrdercode(String thirdcode, String ordercode);
	
	
	void updateAutoClearingByOrdercode(String ordercode, String autoclearing);
	
	PaymentOrder  queryPaymentOrderBycode(String ordercode);
	PaymentOrder  queryPaymentOrderByIdAndCode(int userId, String orderCode);

	PaymentOrder  queryPaymentOrderBycodeAndStatus(String ordercode, String status);
	
	BigDecimal findsumPaymentOrder(long userid, String[] type, String[] status, String autoClearing);
	
	List<PaymentOrder> findsumPaymentOrderByDescCode(long userid, String[] type, String[] status, String desccode, Date startTimeDate, Date endTimeDate);
	
	BigDecimal findsumPaymentOrder(long userid, String[] type, String[] status, String autoClearing, Date startTimeDate, Date endTimeDate);
	
	int findsumPaymentOrderCount(long userid, String[] type, String[] status, String autoClearing, Date startTimeDate, Date endTimeDate);
	
	BigDecimal findsumPaymentOrderBrand(long brand, String[] type, String[] status, String[] autoClearing, Date startTimeDate, Date endTimeDate);
	
	int findsumPaymentOrderBrandCount(long brand, String[] type, String[] status, String[] autoClearing, Date startTimeDate, Date endTimeDate);
	
	BigDecimal findsumPaymentOrderPlatform(String[] type, String[] status, String[] autoClearing, Date startTimeDate, Date endTimeDate);
	
	int findsumPaymentOrderPlatformCount(String[] type, String[] status, String[] autoClearing, Date startTimeDate, Date endTimeDate);

	//根据多个条件查询订单信息
	Map queryPaymentOrderAll(String startTime, String endTime, String phone, String ordercode, String ordertype, String orderstatus, long brandid, Pageable pageAble);
	
	//修改订单号
	PaymentOrder updatePaymentOrder(String orderCode, String orderNo);
	
	//根据phone和brandid查询用户所有订单号
	List<PaymentOrder> findOrderByphoneAndbrandid(String phone, long brandid, Date startTimeDate, Date endTimeDate, Pageable pageable);

	List<Long> queryUserIdsByAmount(Long brandId, BigDecimal limitAmount, Long autoRebateConfigId);
	
	//调用此方法获取待结算订单
	List<PaymentOrder> findOrderByUseridAndStatus(long userid, String[] status);

//	批量查询总金额
	List<Object[]> findSumByUserIds(long[] userIds, String type, String status, String autoClearing);

	
	//将订单失败的信息存入数据库
	void addErrorByOrderCode(String ordercode, String remark);

	Object getWithDrawPage(String status, long userId, int page, int size) throws ServiceException;

	Object getRebatePage(String token, int page, int size) throws ServiceException;

    Object getRechargePage(String status, long userId, int page, int size) throws ServiceException;

	Object getPayPage(String status, long userId, int page, int size) throws ServiceException;
}
